/************************************************************************
 * The code is owned by mainframer.cn and Shang Tao
 * Without aproval of mainframer.cn and Shang Tao, removing the copyright
 * infomation is regarded as invassion of proprietary copyright
 ***********************************************************************/
package com.mr.qa.util;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

public class ActionHelper
{
    public ActionHelper()
    {
    }
    public static String getQueryString(javax.servlet.http.HttpServletRequest request)
    {
        String method = request.getMethod().toLowerCase();
        String queryString = "";
        if("get".equals(method))
        {
            queryString = request.getQueryString();
        }
        if("post".equals(method))
        {
            queryString = getPostFormQueryString(request);
        }
        return queryString;
    }
    private static String getPostFormQueryString(HttpServletRequest request)
    {
        String queryString = "";
        Enumeration e = request.getParameterNames();
        String name = "";
        String value = "";
        while(e.hasMoreElements())
        {
            name = (String)e.nextElement();
            value = request.getParameter(name);
            if(queryString.length() > 0)
            {
                queryString = queryString+"&"+name+"="+value;
            }
            else
            {
                queryString = name+"="+value;
            }
        }
        return queryString;
    }
            
}
